﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.Xml.Schema;

namespace WEEK10_LECTURE
{
    public partial class XmlReaderSettingsExample01 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                //settings.ConformanceLevel = ConformanceLevel.Fragment;
                settings.IgnoreWhitespace = true;
                settings.IgnoreComments = true;
                settings.ValidationType = ValidationType.Schema;
                settings.Schemas.Add(null, Server.MapPath("Employees.xsd"));

                XmlReader reader = XmlReader.Create(Server.MapPath("Employees.xml"), settings);

                while (reader.Read())
                {
                }

                reader.Close();
                Response.Write("文档有效");
            }
            catch (Exception exception)
            {
                Response.Write(exception.Message);
            }
        }
    }
}